package com.chao.yyks.modular.sys.controller;

import com.alibaba.fastjson.JSONObject;
import com.chao.common.util.log.Inter;
import com.chao.common.util.reaction.PageList;
import com.chao.yyks.modular.sys.bean.EnStudent;
import com.chao.yyks.modular.sys.bean.EnTeacher;
import com.chao.yyks.modular.sys.service.EnTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 教师Controller
 * chao
 * 2024-09-09
 */
@RestController
@RequestMapping("/enTeacher")
public class EnTeacherController {

	/**
	 * 教师Service
	 */
	@Autowired
	private EnTeacherService enTeacherService;

	/**
	 * 新增教师
	 */
	@Inter("ETR_ADD_01")
	@RequestMapping(method = RequestMethod.POST, value = "insertEnTeacher")
	public void insertEnTeacher(@RequestBody EnTeacher enTeacher){
		enTeacherService.insertEnTeacher(enTeacher);
	}

	/**
	 * 修改教师
	 */
	@Inter("ETR_EDT_01")
	@RequestMapping(method = RequestMethod.POST, value = "updateEnTeacher")
	public void updateEnTeacher(@RequestBody EnTeacher enTeacher){
		enTeacherService.updateEnTeacher(enTeacher);
	}

	/**
	 * 删除教师
	 */
	@Inter("ETR_DEL_01")
	@RequestMapping(method = RequestMethod.POST, value = "deleteEnTeacher")
	public void deleteEnTeacher(@RequestBody EnTeacher enTeacher){
		enTeacherService.deleteEnTeacher(enTeacher.getTeacherId());
	}

	/**
	 * 修改密码
	 */
	@Inter("ETR_DEL_02")
	@RequestMapping(method = RequestMethod.POST, value = "updatePassword")
	public void updatePassword(@RequestBody JSONObject json){
		enTeacherService.updatePassword(json);
	}

	/**
	 * 重置密码
	 */
	@Inter("ETR_DEL_03")
	@RequestMapping(method = RequestMethod.POST, value = "resetPassword")
	public void resetPassword(@RequestBody EnTeacher enTeacher){
		enTeacherService.resetPassword(enTeacher.getTeacherId());
	}

	/**
	 * 查询教师详情
	 */
	@Inter("ETR_SEL_01")
	@RequestMapping(method = RequestMethod.GET, value = "selectEnTeacherByTeacherId")
	public EnTeacher selectEnTeacherByTeacherId(String teacherId){
		return enTeacherService.selectEnTeacherByTeacherId(teacherId);
	}

	/**
	 * 查询教师列表
	 */
	@Inter("ETR_SEL_02")
	@RequestMapping(method = RequestMethod.GET, value = "selectEnTeacherByList")
	public PageList<EnTeacher> selectEnTeacherByList(@RequestParam Map<String,Object> map){
		return enTeacherService.selectEnTeacherByList(new JSONObject(map));
	}

	/**
	 * 分页查询教师列表
	 */
	@Inter("ETR_SEL_03")
	@RequestMapping(method = RequestMethod.GET, value = "selectEnTeacherByPage")
	public PageList<EnTeacher> selectEnTeacherByPage(@RequestParam Map<String,Object> map){
		return enTeacherService.selectEnTeacherByPage(new JSONObject(map));
	}

}